package com.skycong.hello77;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.SimpleAdapter;

import com.skycong.hello77.activity.InflateTestActivity;
import com.skycong.hello77.activity.calculator.CalculatorActivity;
import com.skycong.hello77.activity.contentmenu.ContentMenuActivity;
import com.skycong.hello77.activity.dialog.DialogActivity;
import com.skycong.hello77.activity.frag.MyFragActivity;
import com.skycong.hello77.activity.fragment.GetValueFraActivity;
import com.skycong.hello77.activity.intent.FirstPageActivity;
import com.skycong.hello77.activity.listview.TestListActivity;
import com.skycong.hello77.activity.login.Login1;
import com.skycong.hello77.activity.notification.NotificationActivity;
import com.skycong.hello77.activity.optionmenu.OptionMenuActivity;
import com.skycong.hello77.activity.order.OrderActivity;
import com.skycong.hello77.activity.personhome.PersonHomeActivity;
import com.skycong.hello77.activity.register.RegisterActivity;
import com.skycong.hello77.activity.spinner.SpinnerActivity;
import com.skycong.hello77.activity.sqlitedb.SQLiteDBActivity;
import com.skycong.hello77.activity.testsmartlayout.activitty.TestSmartLayoutActivity;
import com.skycong.hello77.activity.titlecolor.BaseActivity;
import com.skycong.hello77.activity.toast.ToastActivity;
import com.skycong.hello77.activity.webview.LoadUrlActivity;
import com.skycong.hello77.complexforms.activity.FormActivity;
import com.skycong.hello77.datepicker.DatePickerDialog;
import com.skycong.hello77.tabfragment.activity.TabFragmentActivity;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MainActivity extends Activity implements AdapterView.OnItemClickListener {
    private GridView gridView;
    private SimpleAdapter sim_adapter;
    private List<Map<String, Object>> dataList;
    private Context content;
    private int[] pic = {
            R.mipmap.dingdan_empty_icon,
            R.mipmap.close_btn,
            R.mipmap.ic_map_qdposition,
            R.mipmap.dingdan_empty_icon,
            R.mipmap.dingdan_empty_icon,
            R.mipmap.close_btn,
            R.mipmap.close_btn,
            R.mipmap.close_btn,
            R.mipmap.ic_map_qdposition,
            R.mipmap.ic_map_qdposition,
            R.mipmap.ic_map_qdposition,
            R.mipmap.dingdan_empty_icon,
            R.mipmap.dingdan_empty_icon,
            R.mipmap.ic_map_qdposition,
            R.mipmap.ic_map_qdposition,
            R.mipmap.ic_map_qdposition,
            R.mipmap.dingdan_empty_icon,
            R.mipmap.dingdan_empty_icon,
            R.mipmap.dingdan_empty_icon,
            R.mipmap.dingdan_empty_icon,
            R.mipmap.dingdan_empty_icon,
            R.mipmap.dingdan_empty_icon,
            R.mipmap.dingdan_empty_icon,
            R.mipmap.dingdan_empty_icon,
            R.mipmap.dingdan_empty_icon,
            R.mipmap.dingdan_empty_icon,
            R.mipmap.dingdan_empty_icon,
            R.mipmap.dingdan_empty_icon,

    };
    private String[] text =
            {        "登录",
                    "个人主页",
                    "订单页",
                    "详情页",
                    "邮箱自动补全",
                    "通知",
                    "计算器",
                    "列表页",
                    "测试Toast",
                    "测试Dialog",
                    "注册",
                    "选项菜单",
                    "上下文菜单",
                    "SQLite",
                    "下拉列表",
                    "Fragment",
                    "ViewPagerOwn",
                    "LoadMore",
                    "TableFragment",
                    "GetView",
                    "测试测试",
                    "测试webview",
                    "SmartTest",
                    "IntentTest",
                    "BaseActivity",
                    "时间选择弹框",
                    "很复杂的表格",
                    "测试Fragment",

            };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        content = this;
        setContentView(R.layout.activity_main);
        dataList = new ArrayList<Map<String, Object>>();
        gridView = (GridView) findViewById(R.id.grid_view);
        sim_adapter = new SimpleAdapter(this, getData(), R.layout.grid_item, new String[]{"pic", "text"}, new int[]{R.id.pic, R.id.text});
        gridView.setAdapter(sim_adapter);
        gridView.setOnItemClickListener(this);
    }


    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        switch (text[position]) {
            case "登录": {
                Intent intent = new Intent(content, Login1.class);
                startActivity(intent);
                break;
            }
            case "个人主页": {
                Intent intent = new Intent(content, PersonHomeActivity.class);
                startActivity(intent);
                break;
            }
            case "计算器": {
                Intent intent = new Intent(content, CalculatorActivity.class);
                startActivity(intent);
                break;
            }
            case "订单页": {
                Intent intent = new Intent(content, OrderActivity.class);
                startActivity(intent);
                break;
            }
            case "列表页": {
                Intent intent = new Intent(content, TestListActivity.class);
                startActivity(intent);
                break;
            }
            case "测试Toast": {
                Intent intent = new Intent(content, ToastActivity.class);
                startActivity(intent);
                break;
            }
            case "测试Dialog": {
                Intent intent = new Intent(content, DialogActivity.class);
                startActivity(intent);
                break;
            }
            case "注册": {
                Intent intent = new Intent(content,RegisterActivity.class);
                startActivity(intent);
                break;
            }
            case "通知": {
                Intent intent = new Intent(content,NotificationActivity.class);
                startActivity(intent);
                break;
            }
            case "选项菜单": {
                Intent intent = new Intent(content,OptionMenuActivity.class);
                startActivity(intent);
                break;
            }
            case "上下文菜单": {
                Intent intent = new Intent(content,ContentMenuActivity.class);
                startActivity(intent);
                break;
            }
            case "SQLite": {
                Intent intent = new Intent(content,SQLiteDBActivity.class);
                startActivity(intent);
                break;
            }
            case "下拉列表": {
                Intent intent = new Intent(content,SpinnerActivity.class);
                startActivity(intent);
                break;
            }
            case "Fragment": {
                Intent intent = new Intent(content,MyFragActivity.class);
                startActivity(intent);
                break;
            }
            case "ViewPagerOwn": {
                Intent intent = new Intent(content, com.skycong.hello77.activity.viewpager_own.MainActivity.class);
                startActivity(intent);
                break;
            }
            case "LoadMore": {
                Intent intent = new Intent(content, com.skycong.hello77.activity.recycerview.RecycerViewActivity.class);
                startActivity(intent);
                break;
            }
            case "TableFragment": {
                Intent intent = new Intent(content, TabFragmentActivity.class);
                startActivity(intent);
                break;
            }
            case "GetView": {
                Intent intent = new Intent(content, GetValueFraActivity.class);
                startActivity(intent);
                break;
            }
            case "测试测试": {
                Intent intent = new Intent(content, InflateTestActivity.class);
                startActivity(intent);
                break;
            }
            case "测试webview": {
                Intent intent = new Intent(content, LoadUrlActivity.class);
                startActivity(intent);
                break;
            }
            case "SmartTest": {
                Intent intent = new Intent(content, TestSmartLayoutActivity.class);
                startActivity(intent);
                break;
            }
            case "IntentTest": {
                Intent intent = new Intent(content, FirstPageActivity.class);
                startActivity(intent);
                break;
            }
            case "BaseActivity": {
                Intent intent = new Intent(content, BaseActivity.class);
                startActivity(intent);
                break;
            }
            case "时间选择弹框": {
                Intent intent = new Intent(content, DatePickerDialog.class);
                startActivity(intent);
                break;
            }
            case "很复杂的表格": {
                Intent intent = new Intent(content, FormActivity.class);
                startActivity(intent);
                break;
            }
            case "测试Fragment": {
                Intent intent = new Intent(content, TabFragmentActivity.class);
                startActivity(intent);
                break;
            }
        }

    }
    private List<Map<String, Object>> getData() {
        for (int i = 0; i < text.length; i++) {
            Map<String, Object> map = new HashMap();
            map.put("pic", pic[i]);
            map.put("text", text[i]);
            dataList.add(map);
        }
        return dataList;
    }
}
